package endpoint;

import javax.xml.ws.Endpoint;

import ws.RaspberryPiAdminServerImpl;
import ws.RaspberryPiServerImpl;

public class RaspberryPublisher {
	private static String DOMAINE = "127.0.0.1";
	private static int PORT_SERVER = 9990;
	private static int PORT_SERVER_ADMIN = 9991;
	
	private static String serverURL = "http://" + DOMAINE
			+ ":"+ PORT_SERVER +"/ws/raspberry";
	private static String adminURL = "http://" + DOMAINE + ":9997/ws/admin";
	
	public static String SCRIPT_PATH;

	/**
	 * Lauch programm with options
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		if(args.length != 5){
			System.out.println("Error : 5 parameters needed");
		}
		
		String ipAddressAdmin = args[0];
		String portServerAdmin = args[1];
		String ipAddress = args[2];
		String portServer = args[3];
		SCRIPT_PATH = args[4];
		
		String serverURL = "http://" + ipAddress + ":"+ portServer +"/ws/raspberry";
		String serverURAdminL = "http://" + ipAddressAdmin + ":"+ portServerAdmin +"/ws/raspberry";
		
		RaspberryPiServerImpl rasp = new RaspberryPiServerImpl();

		Endpoint.publish(serverURL, rasp);
		System.out.println("RaspberryPi server lauch succesful at : " + serverURL + "?wsdl");

		
		RaspberryPiAdminServerImpl raspAdmin = new RaspberryPiAdminServerImpl();

		Endpoint.publish(serverURAdminL, raspAdmin);

		System.out.println("ServerAdmin lauch succesful at : " + serverURAdminL + "?wsdl");

	}
}